<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>专用线程 Dedicated Worker —— Inline Worker(DataURL)</title>
</head>

<body>
    <h3>专用线程 Dedicated Worker —— Inline Worker(DataURL)</h3>
    <script>
        if (window.Worker) {
            const url = `data:application/javascript,${encodeURIComponent(
                `postMessage("Dedicated Worker created by Data URL")`
            )}`;
            let worker = new Worker(url);
            worker.onmessage = (e) =>
                console.log(`Main: Received message - ${e.data}`);
        } else {
            console.log("呜呜呜，不支持 Web Worker");
        }
    </script>
</body>

</html>